import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName } from '@/config'

export async function login(data) {
  if (loginRSA) {
    data = await encryptedData(data)
  }
  return request({
    url: '/login/admin_login',
    method: 'post',
    data,
  })
}

export function getUserInfo(accessToken) {
  return request({
    url: '/user/admin_info',
    method: 'post',
    data: {
      [tokenName]: accessToken,
    },
  })
}
export function getUserList(params) {
  return request({
    url: '/user/list',
    method: 'get',
    params,
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post',
  })
}

export function register(data) {
  return request({
    url: '/user/admin_register',
    method: 'post',
    data,
  })
}

export function auditUesr(data) {
  return request({
    url: '/user/audit_uesr',
    method: 'post',
    data,
  })
}

export function editUesr(data) {
  return request({
    url: '/user/edit_uesr',
    method: 'post',
    data,
  })
}

export function disabledUesr(data) {
  return request({
    url: '/user/disabled_uesr',
    method: 'post',
    data,
  })
}

export function deleteUesr(data) {
  return request({
    url: '/user/delete_uesr',
    method: 'post',
    data,
  })
}

// 个人中心-修改账号信息
export function editUesrInfo(data) {
  return request({
    url: '/user/edit_uesr_info',
    method: 'post',
    data,
  })
}

export function editUesrPwd(data) {
  return request({
    url: '/user/edit_uesr_Pwd',
    method: 'post',
    data,
  })
}
